/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication1;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.ArrayList;
import java.util.List;

import java.io.IOException;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import org.apache.commons.lang3.StringEscapeUtils;

/**
 *
 * @author pro4
 */
public class JavaApplication1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        /*    GetExample example = new GetExample();
        String response = example.run("https://163.com");
        System.out.println(response);*/

        PostExample example = new PostExample();
        String json1 = example.bowlingJson("Jesse", "Jake");
        String response = example.post("http://www.roundsapp.com/post", json1);
        System.out.println(response);

        //System.exit(0);

        /*   Map<String, Object> map = new HashMap<String, Object>();
        map.put("0", "制造假数据");
        map.put("1", "下面是一个小示例");
        map.put("2", "存放数组下标和数值");
        map.put("3", "下面开始循环");
        String[] arr = new String[map.size()];
        Set<String> set = map.keySet();
        for (String st : set) {
            arr[Integer.parseInt(st)] = (String) map.get(st);
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.println("arr[" + i + "]:" + arr[i]);
        }
         */

 /*
        try {
            ObjectMapper mapper = new ObjectMapper();

            String json = "";

            Map<String, String> map = new HashMap<String, String>();
            map.put("name", "zitong");
            map.put("age", "26");

            json = mapper.writeValueAsString(map1);

            System.out.println(json);
        } catch (Exception e) {
            e.printStackTrace();
        }*/
        List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
        Map<String, Object> map1 = new HashMap<String, Object>();
        map1.put("tagType", "p");

        map1.put("value", "快快快快快快快");

        map1.put("style", "");

        Map<String, Object> map2 = new HashMap<String, Object>();

        map2.put("tagType", "image");

        map2.put("value", "http://xl.com/upload/default/20190807/20818652bd664d5f9135c85cd5e4e90e.jpg");

        map2.put("style", "");

        Map<String, Object> map3 = new HashMap<String, Object>();

        map3.put("tagType", "image");

        map3.put("value", "http://xl.com/upload/default/20190807/20818652bd664d5f9135c85cd5e4e90e.jpg");

        map3.put("style", "");

        listMap.add(map1);

        listMap.add(map2);
        listMap.add(map3);

        ObjectMapper mapper = new ObjectMapper();
        try {
            String json = mapper.writeValueAsString(listMap);

            System.out.println(json);

        } catch (Exception e) {
        }
        //处理转义json
        String result = "{\\\"Count\\\":\\\"3\\\",\\\"ErrorString\\\":\\\"\\\",\\\"Success\\\":true,\\\"URL\\\":\\\"http:\\\\\\/\\\\\\/172.16.80.65:8080\\\\\\/LoginSSO.aspx?UserCode=wubg&Type=WorkItem\\\",\\\"UserId\\\":\\\"1226\\\",\\\"biztype\\\":\\\"19110\\\",\\\"Results\\\":[{\\\"ActivityId\\\":\\\"6d216e2b-25dc-4978-88a8-2fb5bfbd690c\\\",\\\"ActivityName\\\":\\\"部门负责人\\\",\\\"Money\\\":\\\"\\\",\\\"ParticipantId\\\":\\\"1226\\\",\\\"ParticipantName\\\":\\\"乌宝贵\\\",\\\"PreActivityName\\\":\\\"\\\",\\\"StartTime\\\":\\\"2017\\\\\\/6\\\\\\/21 20:55:59\\\",\\\"State\\\":\\\"0\\\",\\\"Type\\\":\\\"资产处置\\\",\\\"WorkId\\\":\\\"46789861-4dc5-4dd9-87e0-5cb4df8bf3ff\\\",\\\"WorkItemURL\\\":\\\"SBmanager\\\\\\/Equipment_AssetDispose_New.aspx?sitemap=＇所在位置: 生命周期管理 > 资产处置> 部门负责人＇\\\"},{\\\"ActivityId\\\":\\\"05ec02e4-6e11-4791-b2ed-9debf6fef516\\\",\\\"ActivityName\\\":\\\"部门领导意见\\\",\\\"Money\\\":\\\"\\\",\\\"ParticipantId\\\":\\\"1226\\\",\\\"ParticipantName\\\":\\\"乌宝贵\\\",\\\"PreActivityName\\\":\\\"\\\",\\\"StartTime\\\":\\\"2017\\\\\\/6\\\\\\/21 20:41:57\\\",\\\"State\\\":\\\"0\\\",\\\"Type\\\":\\\"资产出库\\\",\\\"WorkId\\\":\\\"56ae6661-4379-4b25-b231-2586609d0e11\\\",\\\"WorkItemURL\\\":\\\"DataBaseBef\\\\\\/Equipment_YANSHOU_CK_NEW.aspx?sitemap=＇所在位置:生命周期管理 > 验收出库 > 部门领导意见＇\\\"},{\\\"ActivityId\\\":\\\"9f0cc043-6bea-446c-90ac-1b228450ebd0\\\",\\\"ActivityName\\\":\\\"使用部门负责人意见\\\",\\\"Money\\\":\\\"\\\",\\\"ParticipantId\\\":\\\"1226\\\",\\\"ParticipantName\\\":\\\"乌宝贵\\\",\\\"PreActivityName\\\":\\\"\\\",\\\"StartTime\\\":\\\"2017\\\\\\/6\\\\\\/21 21:25:56\\\",\\\"State\\\":\\\"0\\\",\\\"Type\\\":\\\"领用出库单\\\",\\\"WorkId\\\":\\\"980ee135-2587-4469-9b5a-8929afcfc728\\\",\\\"WorkItemURL\\\":\\\"SBmanager\\\\\\/Equipment_QL.aspx?sitemap=＇所在位置: 生命周期管理 >  资产领用 > 使用部门负责人意见＇\\\"}]}";
        result = StringEscapeUtils.unescapeJava(result);
        System.out.println(result);

        /*    List<Object> list = new ArrayList<Object>();

        list.add("北京");

        list.add("深圳");

        list.add("上海");
        Object i = list.get(0);

        System.out.println(i);*/
    }

}
